package com.源码分析;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;

import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import reactor.core.publisher.Mono;

// Mono 还有一些独有的静态方法。
// fromCallable()、fromCompletionStage()、fromFuture()、fromRunnable()和 fromSupplier()：分别从 Callable、CompletionStage、CompletableFuture、Runnable 和 Supplier 中创建 Mono
public class FromCompletionStage {

	private Logger logger = LoggerFactory.getLogger(FromCompletionStage.class);

	@Test
	public void test() {
		CompletionStage<String> completionStage = CompletableFuture.supplyAsync(() -> {
			// ForkJoinPool.commonPool-worker-1
			logger.info("helloFuture");
			return "helloFuture";
		});
		// 主线程
		logger.info(Mono.fromCompletionStage(completionStage).block());
	}

}
